function sendForceAjax(queryid,type,id,tableId,zhuID){
	var params = {
		funcName:"query",
		queryId:queryid,
		qParamXML:"<root><params><param name='staff_id' value='"+CONFIG_PARAMS.staff_id+"'></param><param name='center' value=''></param><param name='department' value=''></param><param name='rolegroup' value=''></param></params></root>"
	};
	$.ajax({
		url: localStorage.server_ip+''+CONFIG_PARAMS.app_path+'/clientAdaptor',
	  	dataType: 'xml',
	  	data:params,
		success:function(msg){
			if(type=='table')
				cteateForceTable(id,msg,tableId);
			else
				createForceZhu(id,msg,zhuID);
		}
	});
}

function cteateForceTable(id,xml,tableId){
	var data = {};
	data.title = [];
	data.rows = [];
	$(xml).find("field").each(function(i){
		var label =$(this).attr("name");
		data.title.push(label);
	});
	$(xml).find("row").each(function(i){
	   	var length = $(this).get(0).attributes.length;
	   	var list = [];
		for(var i = 1;i<=length;i++){
			var label =$(this).get(0).attributes.getNamedItem("col"+i).nodeValue;
			if(i==length){
				label = parseInt(label);
				var hour = Math.floor(label/3600);
		     	var minutes = Math.floor((label/60)%60);
		     	var second = Math.floor(label % 60);
		     	label=hour+"时"+minutes+"分"+second+"秒";
			}
			list.push(label);
		}
		data.rows.push(list);
	});
	TABLETOOLS.createTable(data,id,"100%","100",[2],tableId);
}

function createForceZhu(id,xml,zhuID){
	var div = $("<div>").attr("id",zhuID).addClass("graphCss");
	$(id).append(div).height($("#contentWarpper").height());
	var x_name=[];var data2=[];var infoList = [];
	var size=$(id).parent().parent().data("highChartNum");
	$(xml).find("row").each(function(i){
		if(i+1>size && size!=0)
				return false;
		var col1=$(this).get(0).attributes.getNamedItem("col1").nodeValue;
		x_name.push(col1);	
		var col2=$(this).get(0).attributes.getNamedItem("col2").nodeValue;
		var col3=parseInt($(this).get(0).attributes.getNamedItem("col3").nodeValue);
		var col4=parseInt($(this).get(0).attributes.getNamedItem("col4").nodeValue);
		var col5=parseInt($(this).get(0).attributes.getNamedItem("col5").nodeValue);
		var map = {
			time:col1,
			totle_time:col5,
			totle_call:col4,
			totle_num:col3
		};
		infoList.push(map);
		data2.push(col2);
	});
	$('#'+zhuID).highcharts({
        chart: {
            type: 'column',
            backgroundColor:CONFIG_PARAMS.GraphBackColor
        },
        title: {
            text: ''
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            categories: data2,
            labels : { 
        		style:{
        			color:CONFIG_PARAMS.GraphFontColor
        		}
        	}
        },
        yAxis: [{
            title: {
                text: '数量',
                style:{
            		color:CONFIG_PARAMS.GraphFontColor
            	}
            },
            labels : { 
        		style:{
        			color:CONFIG_PARAMS.GraphFontColor
        		}
        	},stackLabels: {
                enabled: true,
                style: {
                    fontWeight: 'bold',
                    color: (Highcharts.theme && Highcharts.theme.textColor) || CONFIG_PARAMS.GraphFontColor
                }
            }
        },{
            title: {
                text: '总通时',
                style:{
            		color:CONFIG_PARAMS.GraphFontColor
            	}
            },
            labels : { 
        		style:{
        			color:CONFIG_PARAMS.GraphFontColor
        		}
        	},stackLabels: {
                enabled: true,
                style: {
                    fontWeight: 'bold',
                    color: (Highcharts.theme && Highcharts.theme.textColor) || CONFIG_PARAMS.GraphFontColor
                }
            },
            opposite: true
        }],
        legend:{
        	itemStyle: {
            	color: CONFIG_PARAMS.GraphFontColor
        	},
        	labels : { 
        		style:{
        			color:CONFIG_PARAMS.GraphFontColor
        		}
        	}
        },
         tooltip: {
			formatter: function() {
                var s = '<b>'+ this.x +'</b>';
                $.each(this.points,function(i,point){
                	var map = point.point.map;
                	s += '<br/><span style="color:red">统计时间: '+ map.time +'</span>';
	                s += '<br/><span style="color:#22B14C">总拨打次数: '+ map.totle_num +'</span>';
	            	s += '<br/><span style="color:#D99815">总通次: '+ map.totle_call +'</span>';
					var hour = Math.floor(map.totle_time/3600);
			     	var minutes = Math.floor((map.totle_time/60)%60);
			     	var second = Math.floor(map.totle_time % 60);
	            	s += '<br/><span style="color:#71BCFA">总通时: '+ hour+"时"+minutes+"分"+second+'秒</span>';
	            	return false;
                });
                return s;
            },
            shared: true
        },
        plotOptions: {
            column: {
            	grouping: false,
            	shadow: false,
                dataLabels: {
                    enabled: true,
                    color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || CONFIG_PARAMS.GraphFontColor,
            		formatter:function(){
            			return this.y || "";
            		}
                }
            }
        },
        series: [{
            name: '总拨打次数',
            type: 'column',
            data: prepare(infoList,"totle_num"),
            dataLabels: {
                color:CONFIG_PARAMS.GraphFontColor
            }
        },{
            name: '总通次',
            data: prepare(infoList,"totle_call"),
            type: 'column',
            dataLabels: {
                color:CONFIG_PARAMS.GraphFontColor
            },
            pointPadding: 0.3
        }, {
        	yAxis: 1,
            name: '总通时',
            type: 'spline',
            data: prepare(infoList,"totle_time"),
            dataLabels: {
                color:CONFIG_PARAMS.GraphFontColor
            }
        }]
    });
}


function prepare(dataArray,key) {
    return dataArray.map(function (item, index) {
        return {y: item[key], map: item};
    });
};